package com.anguin.mylibrary.entity;

import java.util.Objects;

public class CommentEntity
{
    private int commentId;     // 评论ID
    private int bookId;        // 书籍ID，评论属于的书籍
    private int userId;        // 用户ID，评论的发表者
    private String content;    // 评论内容
    private String createdAt;  // 评论时间

    @Override
    public String toString() {
        return "Comment{" +
                "commentId=" + commentId +
                ", bookId=" + bookId +
                ", userId=" + userId +
                ", content='" + content + '\'' +
                ", createdAt='" + createdAt + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CommentEntity commentEntity = (CommentEntity) o;
        return commentId == commentEntity.commentId && bookId == commentEntity.bookId && userId == commentEntity.userId && Objects.equals(content, commentEntity.content) && Objects.equals(createdAt, commentEntity.createdAt);
    }

    @Override
    public int hashCode() {
        return Objects.hash(commentId, bookId, userId, content, createdAt);
    }

    public CommentEntity(){}

    // 构造函数
    public CommentEntity(int commentId, int bookId, int userId, String content, String createdAt) {
        this.commentId = commentId;
        this.bookId = bookId;
        this.userId = userId;
        this.content = content;
        this.createdAt = createdAt;
    }

    // Getter和Setter
    public int getCommentId() {
        return commentId;
    }

    public void setCommentId(int commentId) {
        this.commentId = commentId;
    }

    public int getBookId() {
        return bookId;
    }

    public void setBookId(int bookId) {
        this.bookId = bookId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }
}
